// app.js

const baseURL =require('./utils/baseURL')

App({
  onLaunch() {
    // 展示本地存储能力
    const logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        wx.request({
          url: baseURL.dev+'/wxmini/login',
          data:{
            code: res.code
          },
          success(res){
            console.log('res的data，token:',res.data.data)
            // const userToken =res.data.data
           
            wx.setStorageSync('token',res.data.data) //res.data.data将登录后返回的token存储到缓存中
            const resToken=wx.getStorageSync('token')
            console.log('从story中取出token查看：',resToken)
            console.log('微信小程序登录网络请求发送成功')
          }
        })


      }
    })
  },

globalData: {
	grade: 0,
  reasongrade:0,
  degree:''
}

})
